Object.defineProperty(uni, 'showToastCallBack', {
	configurable: false,
	writable: true,
	enumerable: true,
	value: function(obj, fn) {
		uni.showToast({
			...obj,
			success: () => {
				let duration = obj.duration || 1500;
				let t = setTimeout(() => {
					fn();
					clearTimeout(t)
				}, duration)
			}
		})
	}
})


Object.defineProperty(uni, 'isStrEmpty', {
	configurable: false,
	writable: true,
	enumerable: true,
	value: function(str) {
	    if(str === "" || str === null || str === undefined || str === "null" || str === "undefined"){
			return true;
		}else{
			return false;
		}
	}
})


Object.defineProperty(uni, 'isObjEmpty', {
	configurable: false,
	writable: true,
	enumerable: true,
	value: function(obj) {
		  if(JSON.stringify(obj) == "{}" || obj == "" || obj == null || obj == undefined){
		             return true;
		         }else{
		             return false;
		         }
	}
})

Object.defineProperty(uni, 'setStorageSession', {
	configurable: false,
	writable: true,
	enumerable: true,
	value: function(key,obj) {
		return new Promise((resolve,reject) => {
			  let type = typeof obj;
			  let tmp = "";
			  if(type == "Object"){
				  tmp = JSON.stringify(obj);
			  }else if(type == "string"){
				  tmp = obj;
			  }else if(type == "boolean"){
				  tmp = obj + "";
			  }else if(type == "number"){
				   tmp = obj + "";
			  }else {
				  tmp = obj + "";
			  }
			  
			 sessionStorage.setItem(key,JSON.stringify({
				  data: tmp,
				  type
			 }))
			 resolve(true);
			
		})
	}
})

Object.defineProperty(uni, 'getStorageSession', {
	configurable: false,
	writable: true,
	enumerable: true,
	value: function(key) {
		return new Promise((resolve,reject) => {
			let tmp = "";
			if(sessionStorage.getItem(key)){
				let obj = JSON.parse(sessionStorage.getItem(key));
				
				if(obj.type == "object"){
					tmp = JSON.parse(obj.data);
				}else if(obj.type == "string"){
					tmp = obj.data;
				}else if(obj.type == "boolean"){
					tmp = Boolean(obj.data);
				}else if(obj.type == "number"){
					tmp = Number(obj.data);
				}else {
					tmp = obj.data;
				}
			}
			  
			resolve(tmp);
			
		})
	}
})

Object.defineProperty(uni, 'setStorageSessionSync', {
	configurable: false,
	writable: true,
	enumerable: true,
	value: function(key,obj) {
		console.log("======================",key, typeof obj);
		  let type = typeof obj;
		  let tmp = "";
		  if(type == "object"){
			  tmp = JSON.stringify(obj);
		  }else if(type == "string"){
			  tmp = obj;
		  }else if(type == "boolean"){
			  tmp = obj + "";
		  }else if(type == "number"){
			   tmp = obj + "";
		  }else {
			  tmp = obj + "";
		  }
		  
		  sessionStorage.setItem(key,JSON.stringify({
			  data: tmp,
			  type
		  }))
		  
	}
})

Object.defineProperty(uni, 'getStorageSessionSync', {
	configurable: false,
	writable: true,
	enumerable: true,
	value: function(key) {
		let tmp = "";
		if(sessionStorage.getItem(key)){
			let obj = JSON.parse(sessionStorage.getItem(key));
			
			if(obj.type == "object"){
				tmp = JSON.parse(obj.data);
			}else if(obj.type == "string"){
				tmp = obj.data;
			}else if(obj.type == "boolean"){
				tmp = Boolean(obj.data);
			}else if(obj.type == "number"){
				tmp = Number(obj.data);
			}else {
				tmp = obj.data;
			}
		}
		
		return tmp;
		  
	}
})

Object.defineProperty(uni, 'removeStorageAllSync', {
	configurable: false,
	writable: true,
	enumerable: true,
	value: function() {
		localStorage.clear();
	}
})